package com.sdgakj.service.order;

import com.sdgakj.entity.OrderPay;
import com.sdgakj.repository.OrderPayDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Component
@Transactional
public class OrderPayService {

	private static Logger logger = LoggerFactory.getLogger(OrderPayService.class);

	@Autowired
    private OrderPayDao orderPayDao;
	
    public OrderPay getById(Long id) {
        return orderPayDao.findOne(id);
	}

    /*
     * 更新第三方订单信息
     * 
     * @param entity
     */
    public void updatePrepayOrder(OrderPay entity, String prepayId, String nonceStr) {
        entity.setPrepayId(prepayId);
        entity.setNonceStr(nonceStr);
        entity.setPayTime(new Date());
        orderPayDao.save(entity);
    }

    /*
     * 创建第三方订单信息
     *
     * @param entity
     */
    public void createPrepayOrder(OrderPay entity, String prepayId, String nonceStr) {
        orderPayDao.save(entity);
    }
}
